package com.yanqu.road.entity.player;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@FieldTypeAnnotation(tableName = "t_u_vehicle_bone", desc = "珍兽魂骨")
public class UserVehicleBone extends DataObject {

	@FieldTypeAnnotation(select = true, update = true, desc = "玩家id")
	private long userId;
	@FieldTypeAnnotation(desc = "魂骨id", update = true)
	private int boneId;
	@FieldTypeAnnotation(desc = "魂骨配置id")
	private int configId;
	@FieldTypeAnnotation(desc = "魂骨技能")
	private Map<Integer, Integer> skillMap = new HashMap<>();
	@FieldTypeAnnotation(desc = "装备在什么珍兽身上")
	private String vehicleId="";
	@FieldTypeAnnotation(desc = "装备时间")
	private long equipTime;
	@FieldTypeAnnotation(desc = "装备位置")
	private int equipPos;
	@FieldTypeAnnotation(desc = "是否删除")
	private boolean isDelete;

	public UserVehicleBone() {
	}

	public UserVehicleBone(long userId, int boneId, int configId) {
		this.userId = userId;
		this.boneId = boneId;
		this.configId = configId;
		setInsertOption();
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public int getBoneId() {
		return boneId;
	}

	public void setBoneId(int boneId) {
		this.boneId = boneId;
	}

	public int getConfigId() {
		return configId;
	}

	public void setConfigId(int configId) {
		this.configId = configId;
	}

	public String getVehicleId() {
		return vehicleId;
	}

	public void setVehicleId(String vehicleId) {
		this.vehicleId = vehicleId;
		setUpdateOption();
	}

	public long getEquipTime() {
		return equipTime;
	}

	public void setEquipTime(long equipTime) {
		this.equipTime = equipTime;
		setUpdateOption();
	}

	public boolean getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(boolean delete) {
		isDelete = delete;
		setUpdateOption();
	}

	public Map<Integer, Integer> getSkillMap() {
		return skillMap;
	}

	public void setSkillMap(Map<Integer, Integer> skillMap) {
		this.skillMap = skillMap;
		setUpdateOption();
	}

	public int getSkillLv(int skillId) {
		return skillMap.getOrDefault(skillId, 0);
	}

	public void setSkillLv(int id, int endLv) {
		HashMap<Integer, Integer> tempMap = new HashMap<>(skillMap);
		tempMap.put(id, endLv);
		setSkillMap(tempMap);
	}

	public int getEquipPos() {
		return equipPos;
	}

	public void setEquipPos(int equipPos) {
		this.equipPos = equipPos;
		setUpdateOption();
	}

	public boolean isDelete() {
		return isDelete;
	}

	public void setDelete(boolean delete) {
		isDelete = delete;
		setUpdateOption();
	}


	public void reset(Integer boneInitSkillId) {
		Map<Integer, Integer> tempMap = new HashMap<>();
		tempMap.put(boneInitSkillId, 1);
		this.skillMap = tempMap;
		setUpdateOption();
	}

	public void unEquip() {
		this.vehicleId = "";
		this.equipTime = 0;
		this.equipPos = 0;
		setUpdateOption();
	}
}
